package com.bltec.emergency.mapper;

import com.bltec.emergency.model.ResTeam;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface ResTeamMapper {
    //插入一条resTeam记录
    @Insert("insert into res_team (name,department_id,type,gps_x,gps_y,event_type,strength,category,main_equipment,phone,is_full_time," +
            "create_by,create_time,enable) " +
            "values(#{name},#{departmentId},#{type},#{gpsX},#{gpsY},#{eventType},#{strength},#{category},#{mainEquipment},#{phone},#{isFullTime},#{createBy},#{createTime},#{enable})")
    boolean insert(ResTeam resTeam);

    //通过id设置一条记录为不可用
    @Update("update res_team set enable=0 where id=#{id}")
    boolean setDisableById(Long id);

    //通过id更新一条记录
    @Update("update res_team set name=#{name},department_id=#{departmentId},type=#{type}," +
            "gps_x=#{gpsX},gps_y=#{gpsY},event_type=#{eventType},strength=#{strength},category=#{category},main_equipment=#{mainEquipment},phone=#{phone},is_full_time=#{isFullTime}," +
            "update_by=#{updateBy},update_time=#{updateTime} where id=#{id}")
    boolean updateResTeamById(ResTeam resTeam);

    //查找符合id字段的记录
    @Select("select id,name,department_id,type,gps_x,gps_y,event_type,strength,category,main_equipment,phone,is_full_time,create_time,update_by,update_time,enable" +
            " from res_team where id =#{id} and enable=1")
    ResTeam getResTeamById(Long id);

    //查找所有记录
    @Select("select id,name,department_id,type,gps_x,gps_y,event_type,strength,category,main_equipment,phone,is_full_time,create_time,update_by,update_time,enable" +
            " from res_team where enable=1")
    List<ResTeam> selectAll();
}